package mypackage.servicce.Impl;

import mypackage.bean.Goods;
import mypackage.dao.GoodsDao;
import mypackage.dao.impl.GoodsImpl;
import mypackage.servicce.GoodsService;

import java.util.List;

/**
 * @author YH925
 * @create 2021/12/6 20:41
 */
public class GoodsServiceImpl implements GoodsService {
    private final GoodsDao dao = new GoodsImpl();

    /**
     * 列出所有商品
     * @return 所有商品组成的集合
     */
    @Override
    public List<Goods> selectAllGoods() {
        List<Goods> goods = dao.selectAllGoods();
        return goods;
    }

    /**
     * 根据id查找商品
     * @param id 商品id
     * @return 商品详细信息
     */
    @Override
    public Goods selectGoodsById(String id) {
        return dao.selectGoodsById(id);
    }

    /**
     * 按照价格升序排列
     * @return 排序后的手机
     */
    @Override
    public List<Goods> selectGoodsASC() {
        return dao.selectGoodsASC();
    }

    /**
     * 按照价格降序排列。
     * @return 降序后的手机
     */
    @Override
    public List<Goods> selectGoodsDESC() {
        return dao.selectGoodsDESC();
    }

    @Override
    public List<Goods> selectGoodsByPrice(double begin, double end) {
        return dao.selectGoodsByPrice(begin, end);
    }

    @Override
    public List<Goods> selectGoodsByBrand(String brand) {
        return dao.selectGoodsByBrand(brand);
    }

    @Override
    public double selectGoodsMaxPrice() {
        return dao.selectGoodsMaxPrice();
    }

    @Override
    public double selectGoodsMinPrice() {
        return dao.selectGoodsMinPrice();
    }

    @Override
    public void minusOneGood(String id,int count) {
        dao.minusOneGood(id,count);
    }

    @Override
    public void updateInfo(int choose, String goodsId, Object newInfo) {
        dao.updateInfo(choose, goodsId, newInfo);
    }

    @Override
    public void insert(Goods goods) {
        dao.insert(goods);
    }
}
